import 'package:flutter/material.dart';

/// 基本 label
class BaseFormLabel extends StatelessWidget {

  final bool isRequired;

  final String text;

  final FontWeight fontWeight;

  const BaseFormLabel({Key key, this.isRequired = false, @required this.text, this.fontWeight = FontWeight.normal}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return RichText(
      text: TextSpan(children: [
        WidgetSpan(child: Text('* ', style: TextStyle(color: isRequired == true ? Colors.red : Colors.transparent))),
        TextSpan(text: text, style: Theme.of(context).textTheme.bodyText2.copyWith(fontWeight: this.fontWeight))
      ]),
    );
  }

}
